import Vue from 'vue'
import Vuex from 'vuex'
import  * as types from '../store/types'

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    /*全局配置*/
    user : {},
    token : null,
    title : '',
    systemName:'运维监控'
  },
  getters:{
    getSystemName: (state) => {
      return state.systemName
    }
  },
  mutations:{
    setSystemName: (state, data) => {
      state.systemName = data;
    },
    /*配置公共*/
    [types.LOGIN] : (state,data) => {
      localStorage.token = data;
      state.token = data;
    },
    [types.LOGOUT] : (state,data) => {
      localStorage.removeItem('token');
      localStorage.removeItem('user');
      state.token = null;
    },
    [types.TITLE] : (state,data) => {
      state.title = data;
    },
    [types.USERS] : (state,data) => {
      localStorage.user = JSON.stringify(data);
      state.user = data;
    },
  },
  actions:{

  },
  modules:{

  }
});

export default store
